package Homework.work3;

import java.util.Scanner;

public class and {
        public static void main(String[] args) {
            Scanner scanner = new Scanner(System.in);
            int sum = 0;
            boolean flag = true;// false
            for (int i = 1; i <= 5; i++) {
                System.out.println("请录入第" + i + "门课程成绩:");
                int score = scanner.nextInt();
                if (score < 0 || score > 100) {
                    flag = false;
                    break;
                }
                sum += score;
            }
            if (flag) {
                System.out.println("总和为:" + sum);
            } else {
                System.out.println("该成绩有误，不列入计算!");
            }
        }
    }

